﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ARR.UI.Commands;
using System.Windows.Input;

namespace ARR.UI.ViewModels
{
    public abstract class WorkspaceViewModel : ViewModelBase
    {
        RelayCommand _closeCommand;
        
        protected WorkspaceViewModel()
        {
        }
        
        public ICommand CloseCommand
        {
            get
            {
                if (_closeCommand == null)
                    _closeCommand = new RelayCommand(param => this.OnRequestClose());

                return _closeCommand;
            }
        }

        public bool IsClosing { get; set; }
       
        public event EventHandler RequestClose;

        void OnRequestClose()
        {
            IsClosing = true;

            EventHandler handler = this.RequestClose;
            if (handler != null)
                handler(this, EventArgs.Empty);
        }

    }
}
